import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/task/models/plan.dart';
import 'package:leader_help/utils/util.dart';
import '../index.dart';

class PlanCell extends StatelessWidget {
  const PlanCell({
    Key? key,
    required this.mod,
    this.cellTap,
    this.chooseTap,
    this.canChoose = true,
  }) : super(key: key);
  final PlanModel mod;
  final Function(PlanModel)? cellTap;
  final Function(PlanModel)? chooseTap;
  final bool canChoose;
  @override
  Widget build(BuildContext context) {
    return IntrinsicHeight(
      child: InkWell(
        onTap: () {
          if (cellTap != null) {
            cellTap!(mod);
          }
        },
        child: Container(
          margin: EdgeInsets.symmetric(horizontal: 10.r),
          padding: EdgeInsets.fromLTRB(0, 10.r, 10.r, 10.r),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(8.r),
          ),
          child: Row(
            children: [
              canChoose
                  ? InkWell(
                      onTap: () {
                        if (chooseTap != null) {
                          chooseTap!(mod);
                        }
                      },
                      child: Container(
                        padding: EdgeInsets.symmetric(horizontal: 8.r),
                        child: Icon(
                          mod.isSelected == true
                              ? Icons.check_circle
                              : Icons.circle_outlined,
                          color: mod.isSelected == true
                              ? ColorsUtil.red
                              : ColorsUtil.content,
                          size: 25.r,
                        ),
                      ),
                    )
                  : const SizedBox(),
              Expanded(
                  child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  RichText(
                    text: TextSpan(children: [
                      WidgetSpan(
                        child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 1),
                          margin: EdgeInsets.only(right: 10.r),
                          decoration: BoxDecoration(
                              border: Border.all(color: ColorsUtil.orange)),
                          child: Text(
                            mod.from,
                            style: pfMediumStyle(
                                color: ColorsUtil.orange, fontSize: 12.sp),
                          ),
                        ),
                      ),
                      TextSpan(
                          text: '目标|',
                          style:
                              pfSCStyle(color: ColorsUtil.red, fontSize: 14.sp),
                          children: [
                            TextSpan(
                              text: mod.title,
                              style: pfMediumStyle(
                                color: ColorsUtil.red,
                                fontSize: 14.sp,
                              ),
                            )
                          ]),
                    ]),
                  ),
                  SizedBox(
                    height: 5.r,
                  ),
                  RichText(
                    text: TextSpan(
                        text: '方案简介|资源配置：',
                        style:
                            pfSCStyle(color: ColorsUtil.title, fontSize: 13.sp),
                        children: [
                          TextSpan(
                            text: mod.configure,
                            style: pfMediumStyle(
                              color: ColorsUtil.title,
                              fontSize: 13.sp,
                              height: 1.7,
                            ),
                          )
                        ]),
                  ),
                  SizedBox(
                    height: 5.r,
                  ),
                  RichText(
                    text: TextSpan(
                        text: '行动简介：',
                        style:
                            pfSCStyle(color: ColorsUtil.title, fontSize: 13.sp),
                        children: [
                          TextSpan(
                            text: mod.plan,
                            style: pfMediumStyle(
                              color: ColorsUtil.title,
                              fontSize: 13.sp,
                              height: 1.7,
                            ),
                          )
                        ]),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Container(
                        height: 22.r,
                        margin: EdgeInsets.only(top: 10.r),
                        padding: EdgeInsets.symmetric(horizontal: 10.r),
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                          color: const Color(0xffEF8076),
                          borderRadius: BorderRadius.circular(11.r),
                        ),
                        child: Text(
                          '看详细',
                          style: pfMediumStyle(
                              color: Colors.white, fontSize: 13.sp),
                        ),
                      ),
                    ],
                  ),
                ],
              )),
            ],
          ),
        ),
      ),
    );
  }
}
